﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class ProcessDoing : IAccessible<P_ProcessDoing, ProcessDoing>, ILogicEntity<P_ProcessDoing, ProcessDoing>
    {
        public int ID { get; set; }
        public int Type { get; set; }
        public int ProcessID { get; set; }
        public int ProjectID { get; set; }
        public string ProcessName { get; set; }
        public int SignType { get; set; } 
        public string SignUsers { get; set; }
        public int ChangeState { get; set; }
        public int DoingState { get; set; }
        public DateTime ChangeTime { get; set; }
        public string DoneUser { get; set; }
        public User User { get; set; }

        public ProcessDoing LoadUser(U_User u_user)
        {
            this.User = new User().Set(u_user);
            return this;
        }

        protected override void Covariant(P_ProcessDoing model)
        {
            if (model != null)
            {
                this.ChangeState = model.ChangeState;
                this.ChangeTime = model.ChangeTime;
                this.DoingState = model.DoingState;
                this.DoneUser = model.DoneUser;
                this.ID = model.ID;
                this.ProcessName = model.ProcessName;
                this.SignType = model.SignType;
                this.SignUsers = model.SignUsers;
                this.ProjectID = model.ProjectID;
                this.Type = model.Type;
                this.ProcessID = model.ProcessID;
            }
        }

        protected override P_ProcessDoing Inverter(ProcessDoing model)
        {
            if (model != null)
            {
                return new P_ProcessDoing()
                {
                    ChangeState = model.ChangeState,
                    ChangeTime = model.ChangeTime,
                    DoingState = model.DoingState,
                    DoneUser = model.DoneUser,
                    ID = model.ID,
                    ProcessName = model.ProcessName,
                    SignType = model.SignType,
                    SignUsers = model.SignUsers,
                    ProjectID = model.ProjectID,
                    Type = model.Type,
                    ProcessID = model.ProcessID
                };
            }
            return null;
        }

        public ProcessDoing Set(P_ProcessDoing dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
